<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <!-- <view class="jtop_l" @tap="navigateBack">关闭</view> -->
      <view class="jtop_c">机具领用</view>
      <!-- <view class="jtop_r" @tap="btTC2"><image src="../../static/img/index/ic_add.png"></image></view> -->
    </view>
    <view class="tophr"></view>
    <!-- 
  
  <view class="ci">
    <view class="ci_b">
      <view class="ci_bt"> 总库存(件) </view>
      <view class="ci_bf">
        {{ data_one?data_one:'0'}}
      </view>
    </view>
    <view class="ci_b">
      <view class="ci_bt"> 已领用(件) </view>
      <view class="ci_bf ci_bf2">
        {{ data_two?data_two:'0'}}
      </view>
    </view>
  </view> -->
    <!-- 
    <view class="ttab">
      <view :class="[sj ? 'ttab_t active' : 'ttab_t']" @tap="bt_sj">
        <span>未归还</span>
        <i></i>
      </view>
      <view :class="[sj ? 'ttab_t ' : 'ttab_t active']" @tap="bt_sj">
        <span>已归还</span>
        <i></i>
      </view>
    </view> -->

    <!-- <view class="bl">
      <view class="blb" @tap="to_more">
        <view class="blb_l">
          <view class="blb_lt">
            张三 领用C5型电镐1把
          </view>
          <view class="blb_lf">
            领用时间: 2020.06.07 8:30
          </view>
        </view>
        <image src="../../static/img/jt.png" class="blb_r"></image>
      </view>

      <view class="blb" @tap="to_more">
        <view class="blb_l">
          <view class="blb_lt">
            张三 领用C5型电镐1把
          </view>
          <view class="blb_lf">
            领用时间: 2020.06.07 8:30
          </view>
        </view>
        <image src="../../static/img/jt.png" class="blb_r"></image>
      </view>

      <view class="blb" @tap="to_more">
        <view class="blb_l">
          <view class="blb_lt">
            张三 领用C5型电镐1把
          </view>
          <view class="blb_lf">
            领用时间: 2020.06.07 8:30
          </view>
        </view>
        <image src="../../static/img/jt.png" class="blb_r"></image>
      </view>

      <view class="blb" @tap="to_more">
        <view class="blb_l">
          <view class="blb_lt">
            张三 领用C5型电镐1把
          </view>
          <view class="blb_lf">
            领用时间: 2020.06.07 8:30
          </view>
        </view>
        <image src="../../static/img/jt.png" class="blb_r"></image>
      </view>
    </view> -->

    <!-- 无内容 -->
    <view class="no" v-if="!nodata">
      <view class="no_t">
        <image src="../../static/img/index/2/ic_inventory_grey.png"></image>
      </view>
      <view class="no_c">
        暂无机具领用
      </view>
    </view>

    <view class="bl" v-if="nodata">
      <view
        class="blb"
        @tap="
          to_more(
            item.id,
            index,
            item.name,
            item.totalInventory,
            item.outInventory,
            item.unit,
          )
        "
        v-for="(item, index) in items"
        :key="item.id"
      >
        <view class="blb_l">
          <view class="blb_lt">
            {{ item.name }}
          </view>
          <view class="blb_lf">
            总库存：{{ item.totalInventory ? item.totalInventory : '0'
            }}{{ item.unit }} | 已使用：{{
              item.usedAmount ? item.usedAmount : '0'
            }}{{ item.unit }}
          </view>
        </view>
        <image src="../../static/img/jt.png" class="blb_r"></image>
      </view>
    </view>

    <view class="footerhr"> </view>

    <view class="jfooter2">
      <view class="jfooter_b2 " @tap="jf01">
        <image
          src="../../static/img/index/new/ic_pie chart_normal.png"
          class="jfooter_i2"
        ></image>
        <view class="jfooter_t2">材料库存</view>
      </view>
      <view class="jfooter_b2 active">
        <image
          src="../../static/img/index/new/ic_wrench_fill.png"
          class="jfooter_i2"
        ></image>
        <view class="jfooter_t2">机具领用</view>
      </view>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';

export default {
  data() {
    return {
      repeat_click: true,
      ashowpop: false,
      ashowpop_jrename: false,
      ashowpop_jdel: false,
      ashowpopT: false,
      bj: false,
      yd: false,
      sj: false,

      nodata: true,
      items: [],
      data_one: '',
      data_two: '',
    };
  },
  onShow() {
    request({
      url: `/biz/material-out/list/2`,
      method: 'GET',
      // data: {
      //   type: 2,
      // },

      success: res => {
        console.log('列表', res);
        console.log(res.data.data.length);

        if (res.data.success == true) {
          if (res.data.data.length > 0) {
            this.items = res.data.data;
            console.log(this.items);
            this.nodata = true;
          } else {
            this.items = '';
            this.nodata = false;
          }
        } else {
          this.repeat_click = true;
          uni.showToast({
            title: res.data.msg,
            icon: 'none',
          });
        }
      },
      fail: () => {
        this.repeat_click = true;
        uni.showToast({
          title: '服务器开小差，请稍后~',
          icon: 'none',
        });
        return false;
      },
    });
  },

  methods: {
    add() {
      uni.navigateTo({
        url: '../main/in_addone',
      });
    },
    bt_sj() {
      this.sj = !this.sj;
    },

    to_more(a, b, c, d, e, f) {
      uni.navigateTo({
        url: `../main/in_more_r?a=${a}&b=${b}&c=${c}&d=${d}&e=${e}&f=${f}`,
      });
    },

    // to_more(){
    // 	uni.navigateTo({
    // 		url: '../main/in_addtwo',
    // 	});
    // },

    to_more2() {
      uni.navigateTo({
        url: '../main/in_moretwo',
      });
    },
    jf01() {
      uni.navigateTo({
        url: '../main/in',
      });
    },
    jf02() {
      uni.navigateTo({
        url: '../main/in_use',
      });
    },

    // 跳转
    jshow_pop() {
      // this.ashowpop = !this.ashowpop;
    },
    btTC2() {
      uni.navigateTo({
        url: '../main/in_addone',
      });
    },

    navigateBack() {
      uni.switchTab({
        url: 'main',
      });
    },
  },
  computed: mapState(['forcedLogin', 'hasLogin', 'userName']),
};
</script>

<style>
.tophr {
  width: 100%;
  height: 88rpx;
}
.uni-searchbar {
  box-shadow: none;
}

.no {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 400rpx 0 0;
}
.no_t {
  width: 200rpx;
  height: 200rpx;
  display: block;
  float: left;
  margin: 0 275rpx;
  background: #ffffff;
  border-radius: 200rpx;
}
.no_t image {
  width: 140rpx;
  height: 140rpx;
  display: block;
  float: left;
  margin: 30rpx;
}
.ci {
  width: 750rpx;
  height: auto;
  background: #ffffff;
  float: left;
  margin: 0rpx;
  border-bottom: 20rpx solid #f2f2f2;
  margin-bottom: 20rpx;
}
.ci_b {
  width: 50%;
  height: auto;
  display: block;
  float: left;
  box-sizing: border-box;
  margin: 57rpx 0 0 0;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
}
.ci_bt {
  width: 100%;
  height: auto;
  color: #666666;
  font-size: 24rpx;
  line-height: 32rpx;
  display: block;
  float: left;
  margin: 0rpx 0 0rpx 0;
  text-align: center;
}
.ci_bf {
  width: 100%;
  height: auto;
  color: #000000;
  font-size: 40rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  margin: 12rpx 0 60rpx 0;
  text-align: center;
}
.ci .ci_b:last-child {
  border: 0;
}
.ci_bf2 {
  color: #256aff;
}

.no_c {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 30rpx 0 50rpx;
  color: #666666;
  font-size: 32rpx;
  line-height: 40rpx;
  text-align: center;
}
.no_f {
  width: 460rpx;
  height: 94rpx;
  line-height: 94rpx;
  background: #256aff;
  border-radius: 10rpx;
  display: block;
  float: left;
  margin: 0 145rpx;
  color: #ffffff;
  font-size: 36rpx;
  text-align: center;
}
.no_f:active {
  background: linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.199437),
      rgba(0, 0, 0, 0.199437)
    ),
    #256aff;
}

.bl {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 0px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 0rpx 0 0;
}
.blb {
  width: 720rpx;
  margin: 0 0 0rpx 30rpx;
  height: auto;
  display: block;
  float: left;
  border-bottom: 1px solid #dddddd;
}
/* .bl .blb:last-child{border: 0;} */
.blb_l {
  width: 660rpx;
  margin: 18rpx 0 0rpx 0rpx;
  height: auto;
  display: block;
  float: left;
}
.blb_r {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 43rpx 30rpx 0 0rpx;
}
.blb_lt {
  width: 100%;
  height: auto;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
}
.blb_lt text {
  width: auto;
  height: auto;
  line-height: 42rpx;
  display: block;
  float: right;
  font-size: 24rpx;
  color: #cccccc;
}
.blb_lf {
  width: 100%;
  height: auto;
  line-height: 32rpx;
  display: block;
  float: left;
  font-size: 24rpx;
  color: #999999;
  margin: 10rpx 0 18rpx;
}

.wl_cbox {
  width: 100%;
  height: auto;
  background: #ffffff;
  margin: 88rpx 0 100rpx;
}
.wl_c {
  width: 100%;
  height: 80rpx;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
  overflow: hidden;
}
.wl_cb {
  height: 80rpx;
  padding: 0 0;
  display: block;
  float: left;
  text-align: center;
  font-size: 24rpx;
  line-height: 80rpx;
  color: #000000;
  border-right: 1px solid #dddddd;
}
.wl_c .wl_cb:last-child {
  border: 0px;
}
.wl_cb1 {
  width: 50rpx;
}
.wl_cb2 {
  width: 174rpx;
}
.wl_cb3 {
  width: 130rpx;
}
.wl_cb4 {
  width: 155rpx;
}
.wl_cb5 {
  width: 80rpx;
}
.wl_cb6 {
  width: 150rpx;
  position: relative;
  float: right;
}
.wl_cb6 em {
  height: 8rpx;
  background: #256aff;
  margin: 36rpx 0 0 0;
  display: block;
  float: right;
  position: relative;
  z-index: 2;
}
.wl_cb6 i {
  height: 80rpx;
  padding: 0 0;
  display: block;
  float: left;
  text-align: center;
  font-size: 24rpx;
  line-height: 80rpx;
  color: #000000;
  border-right: 1px solid #dddddd;
  position: absolute;
  top: 0;
  left: 0%;
  width: 33%;
  z-index: 1;
}
.wl_cb6 i.i2 {
  left: 33%;
}

.wl_top {
  width: 100%;
  height: 90rpx;
  background: #f5f5f5;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1000;
  border-bottom: 1px solid #dddddd;
  overflow: hidden;
}
.wl_t {
  height: 58rpx;
  padding: 17rpx 0;
  display: block;
  float: left;
  text-align: center;
  font-size: 20rpx;
  line-height: 28rpx;
  color: #666666;
  border-right: 1px solid #dddddd;
}
.wl_top .wl_t:last-child {
  border: 0px;
}
.wl_t1 {
  width: 50rpx;
  line-height: 56rpx;
}
.wl_t2 {
  width: 174rpx;
  line-height: 56rpx;
}
.wl_t3 {
  width: 130rpx;
}
.wl_t4 {
  width: 155rpx;
}
.wl_t5 {
  width: 80rpx;
}
.wl_t6 {
  width: 150rpx;
  line-height: 56rpx;
}

.doc_bs {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
}
.doc_b {
  width: 720rpx;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
  margin: 0 0 0 30rpx;
}
/* .doc_bs .doc_b:last-child{ border: 0;} */
.doc_bl {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 36rpx 30rpx 36rpx 0;
}
.doc_bt {
  width: auto;
  height: 42rpx;
  line-height: 42rpx;
  font-size: 34rpx;
  display: block;
  float: left;
  color: #000000;
  margin: 37rpx 0 0 0;
}
.doc_br {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 32rpx 30rpx 32rpx 0;
}
.doc_b2 {
  width: 600rpx;
  height: auto;
  display: block;
  float: left;
}
.doc_b2t {
  width: 600rpx;
  height: auto;
  font-size: 34rpx;
  line-height: 42rpx;
  color: #000000;
  margin: 18rpx 0 10rpx;
  display: block;
  float: left;
}
.doc_b2f {
  width: 600rpx;
  height: auto;
  font-size: 24rpx;
  line-height: 32rpx;
  color: #fc9422;
  margin: 0rpx 0 rpx;
  display: block;
  float: left;
}

.index {
  background: #ffffff;
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  box-shadow: inset 0px -1px 0px #dddddd;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_lt {
  margin: 0 0 0 10rpx;
}
.jtop_r {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
}
.jtop_rl {
  margin: 20rpx 30rpx 0 0;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}

.doc_b22 {
  opacity: 0.5;
}

.nd {
  width: 735rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0 0 0 0rpx;
}
.nd_bt {
  width: auto;
  height: 48rpx;
  display: block;
  float: right;
  border: 1px solid #dddddd;
  border-radius: 24rpx;
  margin: 40rpx 0 40rpx 30rpx;
}
.nd_bt text {
  width: auto;
  height: 48rpx;
  display: block;
  float: left;
  margin: 0 7rpx 0 18rpx;
  line-height: 48rpx;
  color: #666666;
  font-size: 24rpx;
}
.nd_bt image {
  width: 13rpx;
  height: 8rpx;
  display: block;
  float: left;
  margin: 21rpx 14rpx 0 0;
}

.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}
.tc_fbox_bt2 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 0rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox_bt3 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-bottom: 1px solid #dddddd;
  background: #ffffff;
}

.ttab {
  width: 100%;
  height: 80rpx;
  display: block;
  float: left;
  border-bottom: 1px solid #dddddd;
  background: #ffffff;
  margin-bottom: 10rpx;
}
.ttab_t {
  width: 50%;
  height: 80rpx;
  display: block;
  float: left;
  background: #ffffff;
}
.ttab_t i {
  width: 30%;
  margin: 0 0 0 35%;
  display: block;
  float: left;
  height: 6rpx;
  background: #ffffff;
}
.ttab_t.active i {
  background: #256aff;
}
.ttab_t span {
  width: 100%;
  height: 74rpx;
  text-align: center;
  display: block;
  float: left;
  line-height: 74rpx;
  color: #666666;
  font-size: 28rpx;
}
.ttab_t.active span {
  color: #256aff;
}
</style>
